<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <body>
        <ui:composition template="./../../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <h:form id="form1" prependId="false">
                    <f:view beforePhase="#{editSupplierManagedBean.initView}">
                        <p:wizard showNavBar="true" showStepStatus="false" widgetVar="wiz" flowListener="#{editSupplierManagedBean.onFlowProcess}">
                            <p:tab title="1" id="supplierDetail">   
                                <p:growl id="tab1" showDetail="true"/> 
                                <p:panel header="Edit Supplier: Supplier Detail" id="detailPanel" style="height:450px;">
                                    <div style="margin-top:50px;margin-left:300px;">
                                        <h:panelGrid id="grid" columns="3">
                                            <h:outputText value="Supplier Name:*" />
                                            <p:inputText  id="supplierName" required="true" requiredMessage="Supplier Name Can not be Blank" value="#{editSupplierManagedBean.supplier.supplierName}" />
                                            <p:message for="supplierName"  />

                                            <h:outputText value="Supplier Email:*"/>
                                            <p:inputText id="email" required="true" requiredMessage="Supplier Email Can not be Blank" value="#{editSupplierManagedBean.supplier.emailAddress}">
                                                <f:validator validatorId="company.managedbean.validation"/>
                                            </p:inputText>
                                            <p:message for="email" />

                                            <h:outputText value="Contact Person Name:*"/>
                                            <p:inputText id="contactPerson" required="true" requiredMessage="Contact Person Name Can not be Blank" value="#{editSupplierManagedBean.supplier.contactPersonName}"/>
                                            <p:message for="contactPerson"/>

                                            <h:outputText value="Contact Number:*"/>
                                            <p:inputMask id="contactNumber" required="true" requiredMessage="Contact Number Can not be Blank" value="#{editSupplierManagedBean.supplier.phoneNumber}" mask="(99)99999999"/>
                                            <p:message for="contactNumber"/>

                                            <h:outputText value="Additional Information:" />
                                            <p:inputText  id="addi" required="false"  value="#{editSupplierManagedBean.supplier.additionalInfo}" />
                                            <p:message for="addi"/>

                                            <h:outputText value="Supplier Address:*"/>
                                            <p:inputText id="supplierStreetName" required="true" requiredMessage="Supplier Address Street Name Can not be Blank" value="#{editSupplierManagedBean.supplier.address.streetName}"/>
                                            <p:watermark value="street name" for="supplierStreetName"/>
                                            <p:message for="supplierStreetName"  />

                                            <p:inputText id="supplierCity" required="true" requiredMessage="Supplier Address City Can not be Blank" value="#{editSupplierManagedBean.supplier.address.city}"/>
                                            <p:watermark value="city name" for="supplierCity"/>
                                            <p:message for="supplierCity"  />

                                            <p:inputText id="supplierPostCode" required="true" requiredMessage="Supplier Post Code Can not be Blank" value="#{editSupplierManagedBean.supplier.address.postCode}"/>
                                            <p:watermark value="post code" for="supplierPostCode"/>
                                            <p:message for="supplierPostCode"  />

                                        </h:panelGrid>
                                    </div>
                                    
                                </p:panel>
                            </p:tab>

                            <p:tab title="2" id="rawMaterialDetail">
                                <p:growl id="tab2" showDetail="true"/>
                                <p:panel header="Edit Supplier: Select Raw Materials" id="rmPanel" style="height:450px;">
                                    <div style="margin-top:50px;margin-left:250px;margin-bottom:50px;">
                                        <p:pickList  immediate="true" id="rm" required="false" value="#{editSupplierManagedBean.rawMaterialDual}" var="rmList"  itemLabel="#{rmList.rawMaterialName}"  itemValue="#{rmList}" converter="PrimeFacesPickListConverter" >  
                                            <f:facet name="sourceCaption">Available</f:facet>
                                            <f:facet name="targetCaption">Assigned</f:facet>
                                        </p:pickList>
                                        <p:commandButton style="margin-top:20px; margin-left:265px;" update="tab2" value="Generate Raw Material List for Pricing"   actionListener="#{editSupplierManagedBean.dualListComplete}" />
                                    </div>
                                </p:panel>
                            </p:tab>

                            <p:tab title="3" id="pricing">  
                                <p:panel header="Edit Supplier: Raw Material Price" id="pricePanel" style="height:450px;">
                                    <div style="margin-top:50px;margin-left:30px;margin-right:30px;height:330px;">
                                        <p:dataTable scrollable="true" height="300" id="supplierPricing" dynamic="true" emptyMessage="No Item to display" value="#{editSupplierManagedBean.supplierLineItemsList}" var ="rmListsForPrice" >
                                            <p:column style="width:500px">
                                                <f:facet name="header">Raw Materials</f:facet>
                                                #{rmListsForPrice.rawMaterial.rawMaterialName}
                                            </p:column>

                                            <p:column style="width:500px">
                                                <f:facet name="header">Price(in Lot Size)</f:facet>
                                                <p:inplace editor="true" onEditUpdate="supplierPricing">
                                                    <p:inputText value="#{rmListsForPrice.price}" />
                                                </p:inplace>
                                            </p:column>
                                        </p:dataTable>
                                    </div>
                                    
                                </p:panel>
                            </p:tab>

                            <p:tab title="confirmation" id="confirm">  
                                <p:growl id="growl" sticky="true" showDetail="true"/> 
                                <p:panel header="Edit Supplier: Confirmation" id="confirmPanel" style="height:450px;">
                                    <div style="margin-top:30px;margin-left:30px;margin-right:30px;height:350px;">
                                        <h:panelGrid id="confirmation" columns="2">  
                                            <h:outputText value="Supplier Name " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.supplierName}" />  
                                            <h:outputText value="Supplier Email " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.emailAddress}" />  
                                            <h:outputText value="Contact Person " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.contactPersonName}" />  
                                            <h:outputText value="Contact Number " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.phoneNumber}" />  

                                            <h:outputText value="Street: " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.address.streetName}" />  

                                            <h:outputText value="City: " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.address.city}" />  
                                            <h:outputText value="Postal Code: " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.address.postCode}" />  

                                            <h:outputText value="Additional Information: " />  
                                            <h:outputText styleClass="outputLabel"  
                                                          value="#{editSupplierManagedBean.supplier.additionalInfo}" />


                                        </h:panelGrid> 
                                        <p:dataTable  scrollable="true" height="150" id="supplierPricing2" dynamic="true" emptyMessage="No Item to display" value="#{editSupplierManagedBean.supplierLineItemsList}" var ="rmListsForPrice"  >
                                            <p:column style="width:500px">
                                                <f:facet name="header">Raw Materials</f:facet>
                                                #{rmListsForPrice.rawMaterial.rawMaterialName}
                                            </p:column>

                                            <p:column style="width:500px">
                                                <f:facet name="header">Price (in Lot Size)</f:facet>
                                                <p:inplace editor="true" onEditUpdate="supplierPricing">
                                                    <p:inputText value="#{rmListsForPrice.price}" />
                                                </p:inplace>
                                            </p:column>
                                        </p:dataTable>
                                    </div>

                                    <p:commandButton style="margin-top:45px;margin-left:870px;" update="growl" value="Confirm"  ajax="true" actionListener="#{editSupplierManagedBean.save}"/>
                                    <p:commandButton style="margin-top:45px;" value="Return" actionListener="#{editSupplierManagedBean.goBack}"/>
                                </p:panel>
                            </p:tab> 
                        </p:wizard>
                    </f:view>
                </h:form>       
            </ui:define>
        </ui:composition>
    </body>
</html>

